var uuid = require('uuid')

module.exports = class extends think.global.service {
  async indexAction() {
    // let res = await think.http.post(this.$url, this.post(), this.$config)
    // this.json(res.data)
    var data = this.post()
    if (data.mobileLogin == 'true') {//手机登录

    } else {
      try {
        let res = await think.http.post(this.$url, this.post(), this.$config)
        if (res.status == 200 && res.statusText == 'OK') {
          var key = uuid.v1()
          if (res.data.status === 1) {
            console.log(res.data.user_info)
            console.log(this.post().type)
            console.log(key)
            this.model('user').adduser(res.data.user_info, this.post().type, key)
          }
          res.data.key = key
          this.json(res.data)
          
        } else {
          throw 'error'
        }
      }catch (e) {
        console.log(e)
        this.ctx.fail(1000, e.message)
      }
    }
  }
};